<template>
   <el-form label-width="100px" class="demo-stus">
    <el-form-item label="商品名" prop="name">
      <el-input v-model="addOrdersData.name"></el-input>
    </el-form-item>
    <el-form-item label="数量" prop="num">
      <el-input v-model="addOrdersData.num"></el-input>
    </el-form-item>
 <el-form-item label="价格" prop="price">
      <el-input v-model="addOrdersData.price"></el-input>
    </el-form-item>
    <el-form-item label="买家地址" prop="address">
      <el-input v-model="addOrdersData.address"></el-input>
    </el-form-item>
    <el-form-item label="状态">
    <el-select v-model="addOrdersData.state" placeholder="请选择">
      <el-option label="有效订单" value="有效"></el-option>
      <el-option label="无效订单" value="失效"></el-option>
    </el-select>
  </el-form-item>
   <el-form-item label="店铺名">
    <el-select v-model="addOrdersData.shopsId" placeholder="请选择">
      <el-option v-for="item in shopsData" :key="item._id" :label="item.name" :value="item._id"></el-option>
    </el-select>
  </el-form-item>
  
  <el-upload
  action="/orders/uploadImages"
  list-type="picture-card"
  :on-success="handleSuccess"
  >
  <i class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
    <el-form-item>
      <el-button type="primary" @click="addOrders">立即创建</el-button>
      <!-- <el-button @click="resetForm('stus')">重置</el-button> -->
    </el-form-item>
  </el-form>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapActions, mapMutations } = createNamespacedHelpers(
  "orders"
);
export default {
computed:{
    ...mapState(['addOrdersData','shopsData'])
},
created(){
this.getShopsAsync()
},
methods:{
    ...mapActions(['addOrdersAsync','getShopsAsync']),
    handleSuccess(response){
      this.addOrdersData.imagePath=response.filename
    },
    async addOrders() {
            const data = await this.addOrdersAsync()
            console.info(data)
           if(data){
             this.$router.push('/StoresSystem/ordersList')
           }
        },
}
}
</script>

<style>

</style>